<?php
namespace app\admin\service;

use app\common\model\Config;

/**
 * 配置-服务类
 * @author 小码哥
 * @since 2020/11/15
 * Class ConfigGroupService
 * @package app\admin\service
 */
class ConfigService extends BaseService
{
    /**
     * 构造函数
     * @author 小码哥
     * @since 2020/11/15
     * ConfigGroupService constructor.
     */
    public function __construct()
    {
        $this->model = new Config();
    }

    /**
     * @return array
     * 获取配置列表
     */
    public function getList()
    {
        // 请求参数
        $param = request()->param();
        // 查询条件
        $map = [];
        $name = getter($param, "name");
        if ($name) {
            $map[] = ['name', 'like', "%{$name}%"];
        }
        // 设置查询条件
        if (is_array($map)) {
            $map[] = ['mark', '=', 1];
        } elseif ($map) {
            $map .= " AND mark=1 ";
        } else {
            $map .= " mark=1 ";
        }
        $field = '';
        $list = $this->model->getAllInfo($map, $field);
        return message("操作成功", true, $list);
    }

}